package edu.nf.ch01.web.admin;

import edu.nf.ch01.common.BaseController;
import edu.nf.ch01.common.ResultVO;
import edu.nf.ch01.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangl
 * @date 2025/4/16
 */
@RestController
@Slf4j
@RequestMapping("/user")
public class UserController extends BaseController {

    @PostMapping("/add")
    public String addUser(User user) {
        log.info(user.getUserName());
        log.info(user.getCard().getCardNum());
        return "success";
    }

    @PostMapping("/add2")
    public String addUser2(
            @RequestParam("userName") String username,
            @RequestParam("age") int age) {
        log.info(username + " : " + age);
        return "success";
    }

    @GetMapping
    public ResultVO<User> getUser(int uid) {
        User user = new User();
        user.setUserName("user1");
        return success(user);
    }
}